﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace fileStream
{
    class Program
    {
        static void Main(string[] args)
        {
            string source = @"D:\Desktop\周杰伦\周杰伦 - 最伟大的作品 [mqms2].mp3 ";
            string target = @"D:\Desktop\最伟大的作品.mp3 ";
            CopyFi1e(source,target);
            Console.WriteLine("复制成功");
            Console.ReadKey();
        }

        private static void CopyFi1e(string source, string target)
        {
            using (FileStream fsRead = new FileStream(source, FileMode.Open, FileAccess.Read))
            {
                using (FileStream fsWrite = new FileStream(target, FileMode.OpenOrCreate, FileAccess.Write))
                {
                    byte[] buffer = new byte[1024 * 1024 * 5];
                    while(true)
                    {
                        int r = fsRead.Read(buffer, 0, buffer.Length);
                        if(r==0)
                        {
                            break;
                        }
                        fsWrite.Write(buffer, 0, r);
                    }
                }
            }
        }

    }


}
